import { ReqPage, ResPage } from '@/api/interface'
import { TBY } from '@/api/config/servicePort'
import http from '@/api'

export namespace VillagePerson {
  /**查询参数 */
  export interface Query extends ReqPage {
    villageId?: number
    year?: string
  }

  /**列表内容 */
  export interface Record {
    id: number
    villageId: number
    year: string
    registeredPopulation: number
    permanentPopulation: number
    labourForce: number
  }

  /**详情 */
  export interface Form {
    id: number
    villageId: number
    year: string
    registeredPopulation: number
    permanentPopulation: number
    labourForce: number
  }
}

// 分页查询
export const pageVillagePerson = (params: VillagePerson.Query) => {
  return http.get<ResPage<VillagePerson.Record>>(TBY + `/village_person/page`, params)
}

// 列表查询
export const listVillagePerson = (params: VillagePerson.Query) => {
  return http.get<VillagePerson.Record[]>(TBY + `/village_person/list`, params)
}

// 详情信息
export const getVillagePersonDetail = (id: number) => {
  return http.get<Partial<VillagePerson.Form>>(TBY + `/village_person/get`, { id }, { loading: false })
}

// 新增或修改
export const saveOrUpdateVillagePerson = (params: Partial<VillagePerson.Form>) => {
  return http.post(TBY + `/village_person/save`, params)
}

// 删除
export const removeVillagePerson = (id: number) => {
  return http.delete(TBY + `/village_person/delete`, { id })
}
